'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 购买挑战次数
 * @author agl
 */

var _ = require('lodash');
var async = require('async');
var moment = require('moment');
var Code = require('../../../../consts/code');
var moduleType = require('../../../../consts/moduleType');
var operationType = require('../../../../consts/operationType');
var configUtil = require('../../../../util/configUtil');
var PlayerManager = require('../../../../libs/playerManager');
var taskService = require('../../../../services/taskService');
var roleService = require('../../../../services/roleService');
var dataApi = require('../../../../libs/dataApi.js');
var actCarbonConf = require('../../../../config/actCarbonConf.js');

module.exports = function (msg, session, next) {
    var gold_conf = actCarbonConf.getCarbonConfByType(1);
    if (!gold_conf) {
        return next(null, {
            code: Code.FAIL
        });
    }
    var food_conf = actCarbonConf.getCarbonConfByType(2);
    if (!food_conf) {
        return next(null, {
            code: Code.FAIL
        });
    }

    var carbon_status = [];
    var week_day = moment().weekday();
    if (week_day === 0) {
        week_day = 7;
    }

    if (gold_conf.open_time.indexOf(week_day) >= 0) {
        carbon_status.push(1);
    }
    if (food_conf.open_time.indexOf(week_day) >= 0) {
        carbon_status.push(2);
    }
    return next(null, {
        code: Code.OK,
        result: {
            carbon_status: carbon_status
        }
    });
};
